Modelling and robust controller design for an underactuated self-balancing robot with uncertain parameter estimation

A comprehensive literature review of self-balancing robot (SBR) provides an insight to the strengths and limitations of the available control techniques for different applications. Most of the researchers have not included the payload and its variations in their investigations. To address this problem comprehensively, it was realized that a rigorous mathematical model of the SBR will help to design an effective control for the targeted system. A robust control for a two-wheeled SBR with unknown payload parameters is considered in these investigations. Although, its mechanical design has the advantage of additional maneuverability, however, the robot’s stability is affected by changes in the rider’s mass and height, which affect the robot’s center of gravity (COG). Conventionally, variations in these parameters impact the performance of the controller that are designed with the assumption to operate under nominal values of the rider’s mass and height. The proposed solution includes an extended Kalman filter (EKF) based sliding mode controller (SMC) with an extensive mathematical model describing the dynamics of the robot itself and the payload. The rider’s mass and height are estimated using EKF and this information is used to improve the control of SBR. Significance of the proposed method is demonstrated by comparing simulation results with the conventional SMC under different scenarios as well as with other techniques in literature. The proposed method shows zero steady state error and no overshoot. Performance of the conventional SMC is improved with controller parameter estimation. Moreover, the stability issue in the reaching phase of the controller is also solved with the availability of parameter estimates. The proposed method is suitable for a wide range of indoor applications with no disturbance. This investigation provides a comprehensive comparison of available techniques to contextualize the proposed method within the scope of self-balancing robots for indoor applications.


Introduction
With growing size of indoor commercial facilities like airports, warehouses, hospitals, and shopping malls need for two-wheel self-balancing robots having provision for the rider is growing. This is a compelling need for social service providers and operation personals to provide state of the art services to the public. Unfortunately, pace of research in this area is slow. A safe and efficient two-wheel SBR is expected to enhance the performance of the indoor commercial facilities.
A reasonable accurate mathematical model of two-wheel self-balancing robot (SBR) including rider and equipped with a controller capable of disturbance rejection and handling uncertainties have to be developed. Suitable parameter estimation approach will make available unknow data to the control system without installing costly measuring sensors and actuators on the robot. A suitable estimation algorithm integrated with the nonlinear controller will make it possible to develop a cost effective and efficient SBR with provision of rider.
Unfortunately, the available solution uses expensive measuring systems to measure unknow parameters or have no rider facility. Best existing approach uses gyroscope and inertial measuring units to measure unknow data and make the solution expensive and cumbersome. We hope to integrate Extended Kalman Filter with Sliding mode controller to simplify the SBR with rider and make it efficient for indoor applications.
Due to theoretical significance of the inverted pendulum, it has been investigated as one of the most fundamental problems in control system theory. It was used time and again to comprehend experimental models, corroborate the efficiency of emerging control techniques, and substantiate their implementations [1,2]. One of its practical applications included a self-balancing twowheeled transport system or a self-balancing robot (SBR). These robots have faster maneuverability which makes them very useful for several applied areas. These systems are a modified form of a simple cart and pendulum system, with wheels located at multiple positions. Modeling and control design of the cart and pendulum system laid the foundation for the required SBR algorithms [3,4]. In literature, fabricated SBR systems range from scaled prototypes to life-size robots. Researchers have carried out extensive modeling of the robot system using Euler Lagrange equations and Newtonian dynamic modeling method. Various control techniques were utilized in the design and implementation of upright stability control for these robots [5][6][7][8].
Different types of self-balancing robots have been used for multiple applications and environments. This calls for a substantial dynamic model of a nonholonomic SBR. Although this problem was investigated earlier, however, the mathematical model encapsulated the dynamics of a riderless prototype with a sluggish control response [9]. As a tradeoff, some nonlinear and perceptual control techniques were used to incorporate robustness against system uncertainties of riderless SBRs. Nonetheless, the disturbance rejection capability of the control system was sluggish and the tilt response had significant oscillations [10,11]. Altan and Hacıoglu have used three-axis gimble system mounted on UAV for external disturbance rejection to solve target tracking problem. However, this system may not be feasible to install on SBR system due to its nature of application and cost [12]. Hence, to delineate an exact SBR mathematically, it is important to consider the variations in payload parameters of the system that cause a mismatch in the model and the actual robot dynamics. This mismatch occurs due to error in the global center of mass and moment of inertia of the system. This can ultimately affect the disturbance rejection capability of the controller [13][14][15]. Although more robust control algorithms have been developed for system stability, however, they allow payload variations within a narrow upper and lower bound [16][17][18][19].
SMC design can be broadly categorized into two parts. The first part deals with the designing of a sliding surface with desirable attributes like tracking and stability. The second part entails the designing of discontinuous control law that makes the sliding surface an invariant Another way of looking at the problem is to link unknown parameters to the known parameters. For instance, variation in mass and height of the payload can generate a pitch angle difference between the geometrical center of the robot and the gravity center of the combined body. Perturbations caused due to this angle can be adjusted using control algorithms [33]. To further increase the effectiveness of the controller, an observer can be designed to identify and compensate for modeling mismatch and add robustness to the control strategy [38]. Although, this is a very effective way to deal with the modeling mismatch, however, these approaches cannot be used in the case of a personal transporter. A controller has been designed and validated for a two-wheeled mobile manipulator whose application and dynamics slightly vary from that of an SBR. Furthermore, the observer estimates the modeling mismatches of the robot mass and manipulator arm length, leaving the parameters of payload undetermined [39]. To deal with modeling uncertainties, a robust control strategy can be devised with adaptive simultaneous stabilization of multiple degrees-of-freedom robot systems. Although the technique looked promising, the varying control gain caused the initial control torque to shoot-up considerably under non-nominal conditions. This can originate problems, considering the saturation limit associated with electric motors [40]. Chand et al investigated Certainty equivalence-based robust sliding mode control for disturbance for maximum power extraction from wind turbine. However, for a reasonable performances an estimation technique is required to integrated with the suggested approach [41]. The rider's height and mass, being variable parameters, may cause a mismatch in the real model of the system by changing moment of inertia and shifting the position of COG of the combined system. Hence, these parameters need to be added to the mathematical model. The rider's mass and height were unknown and cannot be measured easily. A feasible solution was required to address the parameter estimation problem. A generalized estimator has been designed using an EKF that worked in combination with SMC. EKF and its variants has been utilized in literature for the parameter estimation in many systems. It has been used for the aerodynamic model estimation and model uncertainty estimation of airship [42][43][44]. EKF can estimate the mismatch caused by the varying payload parameters. The knowledge of this mismatch has been utilized to minimize the gain of the SMC. Due to phase delays in the system, these low gains have been verified to reduce the initial magnitude and oscillations in the control effort. Therefore, maximizing system performance with a minimum control effort requirement.

Major contributions and novelty: -
• Derivation of the mathematical model of the SBR with the inclusion of variable payload dynamics and their effect on the system states.
• Inclusion of motor parameters with decoupled voltage signals as the control input.
• Design of sliding mode controller for the proposed mathematical model.
• Design of an EKF based parameter estimator.
• Proposed ESMC technique and its comparison with the existing SMC stability method.
• Validation of the results using simulations.
• Comparison of the results with existing techniques to justify novelty.
Section 2 describes the detailed mathematical model for a life-size SBR capable of transporting a human rider. Newtonian modeling approach is used to develop an elaborated model. Through the model equations an insight into the dynamics of SBR is developed. In section 3, Designed of a nonlinear sliding mode control system to regulate the pitch and yaw angle of the SBR is discussed. Sliding surface design needs the information of modeling error. Estimation of error is made through extended Kalman filter and used to design the sliding mode controller. Section 4, investigates the proposed algorithm for EKF based SMC to ensure stability of SBR. The proposed estimation algorithm requires carefully tune the EKF parameters to achieve the required performance. In section 5, controller stability analysis is performed using the SBR model, the sliding surfaces defined, given controllers, and the EKF estimator designed for estimation ofM R andL r . Section 6 covers the discussions on simulations conducted to validate the proposed ESMC balancing control. The objective of these simulations is to demonstrate the enhanced performance of the proposed method on account of the estimations made for M R andL r . and section 7 concludes the investigations with emphasizing major achievements of the proposed algorithms in comparison with existing works in the literature. It also gives a future road map to further research in this field for interested researchers. The actuation and stability of the robot are attained through a feedback control mechanism. An inertial measurement unit(IMU) is embedded in the center of robot's chassis. As the rider is tilted forward, pitch and yaw rate data measured through IMU is fed back to the controller. This information is processed by the controller and generates a control torque command to adjust the states of the robot accordingly. Hence, performing stabilization and actuation action on the SBR, simultaneously. To design an effective control system, the dynamics of the physical body must be modeled mathematically. The model used in this paper is based on the parameters characterizing the robot. Model equations are resulting equations are derived using Newtonian modeling approach. Fig 2 shows the free body diagram (FBD) of the SBR used for the derivation of a mathematical model in this investigation. The FBD is divided into sub-diagrams to effectively extract the equations that represent the dynamics of the system. As the Newtonian method is used to model the system, linear and angular versions of the second law of motion is used to describe the sum of forces and torques, respectively.

Description and modeling of self-balancing robot
Fig 3 shows the sum of torques observed about the z-axis. As a convention for derivation, clockwise torque is taken as positive and counterclockwise torque as negative. Sin θ P component of (V L +V R ) and sin (90−θ P ) component of (H L +H R ) generate the required torques. Since, sin (90 −θ P ) = cos θ P , both H L +H R and C L +C R generate counterclockwise torques and (V L +V R ) contribute to the clockwise torque. Eq (3) represents the sum of torques observed about the z-axis.  All the forces are directed towards the right-hand side. Hence, using Newton's second law of motion, sum of these forces can be represented by Eq (6).
Fig 5 shows the force vector diagram of the horizontal reaction forces between wheels and chassis, and the disturbance force at the COG of the robot. Fig 6 shows the force vector diagram of the vertical reaction forces between wheels and chassis. F Cθ , M g are acting at the COG. These forces act on the chassis along the y-axis. Upward forces were taken as positive, whereas downward forces as negative. Using this convention, the sum of forces on the chassis along the y-axis are given by Eq (7). The cosine component of this force is same as F Cθ . Where γ = 180−90−θ P reduces to γ = 90−θ P . Since cos (90−θ P ) = sin θ P , therefore, F Cθ can be written by using Eq (8).

PLOS ONE
equal to the sum of the average distance traveled by the wheel circumference and the sin component of the distance of COG from the z-axis.
Fig 9 depicts the force vector diagram representing the components of L for the distance traveled along the y-axis. It has been assumed that the wheels of the robot do not leave the surface but the movement of the handlebar along the y-axis can be associated with its changing height due to the change in tilt angle. It could be seen that with the change in angle θ P , the component of length Lcos(θ P ) that is along the y axis, changes as well. Hence, the displacement in the y-direction at any point can be given by the difference between the total length and the component of length along the y-axis.  (20). Forces acting at moment arm generate torque along the axis of rotation of the wheels. Using Newton's second law for rotational bodies, the sum of these moments for the left and right wheels are represented in Eqs (11) and (12). and The generated torque rolls the wheel and covers a distance. It may be represented as the sector of the wheel having a radius R. The sector length for both wheels is given by Eqs (14) and (15) y ¼ À L À ðÀ L cos y P Þ ð13Þ or y ¼ À Lð1 À cos y P Þ Using Newton's second law of motion, sum of forces acting on the wheel along the x-axis are given in Eqs (16) and (17). and Similarly, Eqs (18) and (19) represent the sum of forces along the y-axis.
and Linear movement of chassis are characterized by the position x wm that is the average of the sector length covered by the circumference of two wheels. This can be written as in Eq (20).
Fig 10 shows the force vector diagram of the chassis representing the yaw angle (δ). The robot has a yaw rotation when there is a difference in the rotation rate of the wheels. Yaw

PLOS ONE
angle (δ) can be represented in terms of difference between the distance covered by the two wheels. Eq (22) is used to represent the yaw angle δ.
where δ is positive for X WL >X WR and vice versa. The wheels are characterized as circular discs and both have the same mass and radius. Therefore, their moment of inertia can be expressed by Eq (23).
The total moment of inertia of the system is characterized as the sum of the rider's moment of inertia and the chassis moment of inertia. The robot's moment of inertia is calculated using an Autodesk inventor model of the robot and has turned out to be equal to 1.49 kgm 2 . Rider's moment of inertia is approximated as that of a cylinder to simplify the model. As the moment of inertia for a cylindrical body can be represented as 1 3 ML 2 , therefore, the total moment of inertia of the system is represented by Eq (24).

PLOS ONE
Where and Fig 11 shows a free body diagram of the rider and its contribution to the value of L. This distance is represented using the center of mass equation with two-point masses. Mass of the rider M R is represented as a point mass at 0.55 L r . This value is chosen because the center of gravity (COG) for an average human being lies around that height. Similarly, the mass of the robot M V is represented as a point mass at the center of the rod h 2 . The sum of these two-point masses was characterized as M = M R +M V yielding the following Eq (27). When voltage (v l/r ) is applied to the motor terminals, current (i) flows in its armature. This current passes through the resistor (r) inductor (L) pair and generates a torque (C L/R ). This torque is represented by Eq (28).
The current carrying coil of the motor is placed in a magnetic field and hence generates a back emf v e . This back emf can be approximated as a linear function of the velocity of the robot's wheel.
Application of Kirchhoff's voltage law on the model results in Eq (30).
Newton's second law of motion states that the sum of all the torques acting on the shaft is linearly related to its acceleration by the inertial Load J R . The preceding statement is written in Eq (31).
Where, K f and t a are taken as the frictional constant of the motor and load torque on the motor shaft, respectively.
To yield the differential equations that can represent the dynamics of the SBR, all the preceding equations are utilized. Eqs (6) and (9) were substituted into Eq (3) to yield Eq (32).
Eq (20) is substituted into Eq (10) and the double derivative of the resultant equation is calculated. After multiplying cos (θ P ) on both sides of the equation, Eq (33) is deduced.
Eq (20) is substituted into Eq (10) and double derivative of the resultant equation is evaluated. The resultant equation is formulated as Eq (41) is substituted in Eq (40). The resultant equation yields as Eq (42).
For an effective model including motor dynamics, a relationship between motor voltages v l , v r and the control torque of the wheel C L , C R is derived. Eq (29) is substituted into Eq (30). The resultant equation is rearranged and written as Eq (43).
Here, inductance L i of the motor is assumed to be zero. Eq (28) is substituted into Eq (31) to yield Eq (44).
Motor frictional constant K f and applied torque on the motor t a are approximated as zero.
Eq (43) is substituted into Eq (44) resulting in Eq (45) A combination of Eqs (44), (45), (14) and (15) is used to formulate following equations for the left and right motor of the SBR. and Equations for the pitch and yaw angle control torques C θ and C δ are formulated as functions of pitch and yaw angle control voltages v θ and v δ , respectively. This has been done using Eqs (46), (47), (20) and (22). and Where, v θ = v l +v r and v δ = v l +v r . Decoupling of these control terms lead to individual voltages for the left and the right wheel. This is done using the Eqs (50) and (51). and System of Eqs (33) and (42) are solved simultaneously to formulate differential equations that represent dynamics of the system. Eq (48) is then substituted into the resultant differential equations to deduce Eqs (52) and (53). and Where On the other hand, Eqs (11), (12), (14), (15), (16) and (17) are used to infer yaw angular acceleration. and Eq (55) is subtracted from Eq (54) to yield Eq (56).

Design of sliding mode controller for self-balancing robot
A nonlinear sliding mode control system is designed to regulate the pitch and yaw angle of the SBR. In practical systems, it may not be possible to measure the parameters of the system with reasonable accuracy. Which causes modeling error and as a result, the stability of the system is compromised. Therefore, it is important to ensure the stability of the system against modeling errors. To achieve this, EKF is used in coordination with the SMC, which increases the robustness of the system against modeling errors. SMC is a variable structure control method that alters the dynamics of the nonlinear system by applying a discontinuous control signal. This signal forces the system to "slide" along the system's normal behavior. SMC design can be broadly categorized into two parts. The first part deals with the designing of a sliding surface with desirable attributes like tracking and stability. The second part entails the designing of discontinuous control law that makes the sliding surface an invariant set. This control law also ensures that the sliding surface has finite time reachability. Sliding surface design requires the knowledge of estimation error. The estimation errors for pitch and yaw angle are defined in Eqs (59) and (60) as the difference between the measured and desired pitch & yaw angles, respectively.
Hence, the sliding surface is defined as the error based linear hyperplane shown in Eqs (61) and (62) Where a θ and a δ are tuning variables that must be positive integers to ensure convergence of error to zero. After designing the sliding surfaces, an appropriate reaching law is designed. This law ensures the convergence of the measured angle to the sliding surface and keeps it there. Although SMC is a very efficient controller, using the sine function generally causes the problem of chattering. As a solution, a reaching law with tanh as shown in Eqs (63) and (64) is used.
Where K θ and K δ are controller gains for pitch and angle control, respectively. These gains can be tuned to achieve the desired performance. For the angles to reach the sliding surface, the reachability conditions must be satisfied i.e. S y _ S y < 0 and S d _ S d < 0. To validate these conditions, we have assumed _ S y ¼ À K y tanhðS y Þ and _ S d ¼ À K d tanhðS d Þ. Controller equations for both pitch and yaw may be derived using the reaching law, sliding surface, and the estimation error. Substituting Eqs (61) and (62) into Eqs (63) and (64), respectively, lead to Eqs (65) and (66).
Substituting the values of € y P and € d from Eqs (52) and (58) in Eqs (67) and (68), respectively, then rearranging the controller equation for pitch and yaw angle, their respective control laws can be deduced. They are represented in Eqs (69) and (70). Where Where and it is assumed that D δ = 0. EKF algorithm is a nonlinear extension of the Kalman filter. It gets the first-order linear approximation of the nonlinear system at each sampling time. For this sampling time, it acts as a linear Kalman filter. It is utilized widely in several real-world applications for the estimation of unknown and un-measurable system states, unknown parameters, faults, and disturbances.
In this proposed technique, riders' mass M R and length L r are estimated. This estimation is based on the convergence of the measured and calculated state values. EKF algorithm implementation is divided into two steps: prediction and correction. The process noise and measurement noise covariance matrixes are represented by Q m and R m , respectively. P k is the state error covariance matrix. Fig 13 shows Prediction is carried out in two steps. In the first step, states are predicted for the next sampling instant using the previous state estimates. In the second step, the state error covariance matrix is predicted for the next sampling instant using the model Jacobian matrix and process noise covariance matrix. Correction is accomplished in three steps. In the first step, Kalman filter gain K is calculated using the predicted state error covariance matrix. In the second step, states are corrected using available measurements and Kalman gain. In the third step, the prediction of the state error covariance matrix is made.

Proposed algorithm for SBR control system design
Modeling mismatch affects the performance of the control system; hence, estimation of model uncertainties ensures the improved performance of SMC beyond the given bounds in the literature. An Extended Kalman Filter is used to estimate model uncertainties ofM R andL r . shows the block diagram for the proposed Extended Kalman Filter based Sliding Mode Controller (ESMC). The desired pitch θ Pd and yaw angle δ d are fed to the SMC. The value of θ Pd is kept zero and δ d changes according to the turn command given by the rider. For the purpose of simulation, it is taken as a sinusoidal signal. The states calculated by the differential equations in the SBR simulator are also fed to the SMC. These states are represented as X ¼ ½θ P ; _ θ P ; x wm ; _ x wm ; δ; _ δ�. EKF estimates the values ofM R andL r . These values go into SMC as inputs as well. SMC utilizes these inputs to generate the control effort U = [v θ , v δ ]. This is provided to the SBR simulator containing the dynamic equations of the system, ensuring its stability as per the desired angles. EKF takes X and U as inputs and estimates the values of rider's massM R and lengthL r . Fig 15 gives the flow chart of the proposed algorithm for efficient regulation of desired angles and stability. The SBR simulator is initialized with initial states X 0 . In the next step SBR simulator receives the control inputs U 0 . As the system under examination is an underactuated one, it tends to destabilize. Resulting states of the system X along with the inputs U 0 are fed to the EKF. The dynamic model of the SBR implemented in EKF contains the nominal values of the rider's mass and length. EKF calculates the system's statesXð½1 : 6�Þ based on these nominal values. It then compares them to the states X measured by the SBR simulator which contains the actual information of the rider's mass and length in its dynamic model equations. Since both EKF and the SBR simulator use the same inputs at any given time, the difference betweenXð½1 : 6�Þ and X states can only be justified by some unknown value. In this proposed method, all disturbances are ignored due to its limitations for the indoor environment applications. However, variations due to the rider's mass M R and length L r are examined. EKF tries to minimize the difference between the calculated states by estimating these values. The SMC block implements the proposed stability control method.
It utilizes the estimates of EKF, calculated system states X, and the desired angles and their derivative to calculate the control action necessary to attain system stability. It is then fed back to the EKF and SBR simulator to start this process all over again. This loop runs until the criteria given in Eq (71) is satisfied. With each iteration, EKF tends to converge its estimate (M R andL r ) to the actual values of M R and L r .
Two types of tuning parameters are used in this manuscript. The first refers to the controller gains that include the sliding surface gains (a θ , a δ ) and the switching law gains (K θ , K δ ). The sliding surface gains should be positive to ensure the asymptotic decay of the error. The switching law gains are chosen to ensure the robustness properties of the controller. High controller gains may ensure superior robustness; however, it will require high control effort to swiftly attain stability. This high gain not only causes oscillations due to the inherent phase lag in the system but also drops the energy efficiency of the system. The robustness of the controller is also linked to the availability of accurate model information. If the model is accurately known and is subjected to zero disturbances, then the small controller gains will serve the purpose in both nominal and robust scenarios. However, in real-world scenarios, the model information cannot represent the physical system with absolute accuracy. That calls for the design of SMC with high controller gains to achieve robustness characteristics. In the proposed work, we have ensured the accurate availability of modeling information by pinpointing the parameters that are more vulnerable to the changes. These parameters are estimated online and provided to the controller. Consequently, we have ensured the small gains to achieve robust and nominal performance. The gains are heuristically chosen to best fit the closed-loop performance of the system.
The second type of parameter refers to the tuning variables of the Extended Kalman Filter. Three tuning parameters are required to carefully tune in Kalman filter estimation algorithms. They are P 0 , Q, and R. P 0 is the initial state error covariance matrix having only diagonal entries that refers to the initial error of system states y P ; _ y P ; x wm ; _ x wm ; d; _ d; M R ; L r . The pitch angle, pitch rate, yaw angle, yaw rate, forward distance traveled, and forward velocity are measured using the IMU package. The possible initial error due to the measurements of IMU is considered here. Moreover, the possible initial error of mass of the rider and its length are considered ±30% of the nominal values. The parameter Q refers to the state covariance matrix. Its values correspond to the modeling errors in the dynamic equations. The modeling errors in the dynamic model are minor, however, the rate of change of rider mass and its length is assumed to be zero because it will not vary during the ride of Segway. It will only be uncertain at the start of the ride. The modeling deficiency of the rider's mass and length is accommodated by selecting high gains of the corresponding entries of the Q matrix. The tuning of the measurement matrix R is done by the possible measurement errors of IMU.

Controller stability analysis
Using the SBR model given in the Eqs (54) and (60), the sliding surfaces defined in Eqs (61) and (62), the controllers defined in Eqs (69) and (70), and the EKF estimator designed for esti-matingM R andL r will stabilize the closed-loop system. The two control laws will perform the upright stability task and tracking of yaw command, respectively. That follows with the errors defined in Eqs (59) and (60) asymptotically approaching zero. Selecting the Lyapunov function given in Eq (72).
Figs 16 and 17 depict the convergence ofM R andL r to M R and L r , respectively. This convergence leads to the equation of following terms. A ¼Â; B 1 ¼B 1 ; C 1 ¼Ĉ 1 , and A 3 ¼Â 3 . Taking into account these equations, Eq (75) can be rewritten as Eq (76).
Remark Hence, The ESMC controller ensures the Lyapunov stability of the SBR defined by Eqs (54) and (60). The controller ensures that the errors defined in Eqs (59) and (60) asymptotically converge to zero within a finite time. In the proposed method, EKF made an estimate ofM R andL r and provides that information to the SMC. The method ensures the closed-loop stability of the system. The proposed method also mitigates the chattering issues that usually come due to the selection of large controller gains for robustness in the conventional SMC. The performance of the proposed ESMC control scheme is evaluated using rigorous simulations for different cases.

Results and discussion
Simulations are conducted to validate the proposed ESMC balancing control. System parameters used for this purpose are listed in the nomenclature and acronyms section. The objective of these simulations is to demonstrate the enhanced performance of the proposed method on account of the estimations made forM R andL r . This includes the illustration of improved performance at low K θ gain. Ultimately leading to reduced initial magnitude and oscillations in the control effort. Therefore, maximizing the performance of ESMC with a minimum control effort requirement. The simulation scenarios emulate 7 cases to effectively depict the performance comparison between ESMC and SMC systems. Cases 1-4 consider the 'upper limit' of the payload with M R = 200 kg and L r = 3 m. It starts with the comparison of ESMC and SMC at similar gains for K θ . Progressively, the gain K θ increases, effectuating the performance of the SMC system to approach the ESMC system. Finally, a combination of low K θ gain for ESMC and high K θ gain for SMC is used in such a way that the performance of the SMC based system becomes better than the ESMC based system. The control efforts of the two systems are then compared to justify the proposed solution. Cases 5-7 consider the 'lower limit' of the payload with M R = 0 kg and L r = 0 m. To justify the solution at the lower limit, a similar progressive scheme is used as in cases 1-4. For the upper and lower limits discussed in these cases, EKF is used for estimation. Fig 16 shows the simulation results of EKF estimates for the upper limit of unknown parameters. This is done using the proposed algorithm discussed in the previous section. Initial values that initiate the iterative estimation process are taken as the nominal values of the system parameters. For M R and L r , they are taken as 80 kg and 1.8 meters, respectively. Performance of the proposed technique is tested under extreme payload variations. For mass and length, variations in addition to the ones caused by the dynamics of the rider are incorporated e.g. the mass and length of something being carried by the rider. EKF converges to 96% and 86.6% of the true value of the rider's mass and length respectively in 0.5 seconds. It takes 3.3 seconds for the EKF to achieve 100% convergence. There is an overshoot of 6% in the estimation of the rider's length. This is due to the relatively low quantitative variation of the length from the nominal value as compared to the mass. Fig 17 shows the simulation results for the lower limit. It takes 0.28 seconds for the EKF to achieve 100% convergence. Due to low inertia of the system, EKF converges relatively quickly. This speed comes with an undershoot that is settled instantly. These estimation results are fed to the SMC and the performance comparison of ESMC and SMC based systems is made for the 7 cases. K θ = 2, a θ = 1, K δ =  1, a δ = 1 and upper limit of M R , L r Initially, the Theta controller gain K θ is taken as 2 for both ESMC and SMC based systems. The controller tuning variable for error convergence a θ is taken as 1. As our main concern is pitch angle stability, the gains for K δ and a δ are taken as 1 throughout the case study. Fig 18 shows a comparison of system response of the two systems for the states: pitch angle (θ P ), yaw angle (δ), distance (x wm ), and velocity ( _ x wm ). At this gain, SMC based system becomes unstable, but the ESMC manages to stabilize. For the proposed ESMC based system, θ P and δ meet the desired angle demand. It also maintains a relatively constant position with negligible velocity. In the SMC based system, however, θ P starts oscillating. This jerky motion causes the position of the vehicle to change with an oscillating velocity. Also, δ deviates from its desired trajectory. Case 2: Comparison between ESMC and SMC for gains K θ = 6, a θ = 1, K δ = 1, a δ = 1 and upper limit of M R , L r Fig 19 shows the performance comparison at K θ = 6 for the two systems. Unlike case-1, the SMC based system stabilizes at this gain. This is the minimum control gain at which the SMC based system becomes stable. Although, θ P deviation is extremely small for the SMC based system, however, it fails to reach the desired angle value even after 20 seconds. To ensure system stability, the velocity of the vehicle increases and so does the distance covered. This delay causes the system to reach a high velocity by the time θ P becomes zero. On the other hand, the ESMC based system stabilizes within 2 seconds with negligible velocity and distance covered. δ tracks the desired angle faster with the ESMC based system with the max difference of 0.012 rad between the two systems. Table 1 shows the maximum difference between the states of the two systems with ESMC based system leading in performance. K θ = 50, a θ = 1, K δ =  1, a δ = 1 and upper limit M R , L r Fig 20 shows simulation results for case 3. For both the systems, the controller gain K θ is taken as 50. With the progressive increase in controller gain, performance of both SMC and ESMC tend to approach one another. This is because, at such high gain, SMC becomes robust enough to tackle the uncertainties that previously were affecting the system's performance. However, the proposed method of ESMC based system still outperforms the SMC based system. This shows the effectiveness of estimation even at high controller gains. δ still tracks the desired angle faster with the ESMC based system with the max difference of 0.012 rad between the two systems.  Table 2 shows the maximum difference between the states of the two systems with ESMC based system performing slightly better than the SMC based system. Case 4: Comparison between ESMC having gains K θ = 2, a θ = 1, K δ = 1, a δ = 1 and SMC having gains K θ =50, a θ = 1, K δ = 1, a δ = 1 and upper limit M R , L r Figs 21,22 show the performance and control effort results for case 4. It is evident from the previous cases that increased K θ gain improves the performance of the SMC based system. Hence, in this case, a comparison between high K θ gain SMC based system and low K θ gain ESMC based system is examined. Although, this combination shows that the system with SMC gives a better performance, its high gain demands a very high initial control effort of 9.8 volts to stabilize the underactuated system. That can cause problems in a system with low saturation voltage electric motors. It also affects the energy efficiency of the system. Alternatively, the ESMC based system estimates the values of the rider's mass M R and length L r . This estimation enables the system to operate with a low K θ gain of 2. This reduces the initial voltage spike in the control effort to just 0.8 volts. δ tracks the desired angle faster with the ESMC based system  still. The max difference between the δ angle of the two systems is of 0.012 rad. This demonstrates the use of estimation and the effectiveness of the proposed method when M R = 200 kg and L r = 3 m. Table 3 shows the maximum difference between the states and the control effort of the two systems where SMC based system's performance is better than the ESMC based system except for δ angle. Control effort response of the system with ESMC is better.

PLOS ONE
Case 5: Comparison between ESMC and SMC for gains K θ = 6, a θ = 1, K δ = 1, a δ = 1 and lower limit M R , L r With the conclusion of the upper limit, the simulation is turned towards the lower limit of the payload. This scenario indicates that there is no rider or payload. Fig 23 shows the results of case 5. Due to the absence of payload, the system has a lower moment of inertia. Hence, its stabilization is relatively easy. Apparently, θ P stabilizes more effectively with the SMC based system but ends up generating much more velocity in comparison to the ESMC based system. This increased velocity further deviates the position of the vehicle. This happens because the system falls backward initially due to its low inertia. The ESMC based system is aware of this  response and does not over actuate the system. The initial velocity spike brings θ P back to zero from negative. Hence, reducing the net velocity due to cancellation of the positive velocity effect with θ P stabilization. This in return leads to a smaller displacement from the starting position at a given point in time. δ tracks the desired angle slightly better with the SMC based system for the initial few seconds. After reaching the sliding surface, both systems give the same performance for δ tracking. Table 4 shows the maximum difference between the states of the two systems. θ P stability and δ tracking response are better for the SMC based system. Whereas distance and velocity responses are better for the ESMC based system. Case 6: Comparison between ESMC and SMC for gains K θ = 50, a θ = 1, K δ = 1, a δ = 1 and lower limit M R , L r Figs 24,25 show the simulation results of case 5 implementing a strategy similar to the upper limit cases. Increase in K θ gain to 50 results in approximately similar performance outcome for both of the systems. However, the controller without EKF tends to experience chattering in the  control effort for a longer period as compared to the one with EKF. Furthermore, θ P , _ x wm , and v θ response oscillates initially for both of the systems. This happens due to the high gains used in a low inertial system with no payload. These oscillations come to a halt after 0.01 seconds in the ESMC based system and 0.04 seconds in the SMC based system. The position response of both systems is the same. δ tracks the desired angle slightly better with the SMC based system for the initial few seconds. After reaching the sliding surface, both systems give the same performance for δ tracking. Table 5 shows the maximum difference between the states and the control effort of the two systems. θ P stability and velocity response are better for the ESMC based system. δ tracking response is better for the SMC based system whereas distance response is the same for both systems. Control effort v θ gives a better response with ESMC based system. Case 7: Comparison between ESMC having gains K θ = 2, a θ = 1, K δ = 1, a δ = 1 and SMC having gains K θ = 50, a θ = 1, K δ = 1, a δ = 1 and lower limit M R , L r Figs 26,27 show the performance and control effort v θ response for case 7. Similar to case 4, in this comparison, the performance of the systems is observed under a low K θ gain for ESMC  based system and a high K θ gain for the SMC one. As expected, the SMC based high K θ gain, system performs considerably better when it comes to system states. Apart from the initial oscillations in θ P and the system velocity, the pitch angle deviates 0.00017 rad less from the desired θ P in the SMC based system. After 1 minute, the SMC based system face 0.13 meter less displacement from the starting point as compared to the ESMC one. This is due to the difference in the velocity between the two which is 0.002 m/s. δ also slightly performs better in the SMC based system. However, the initial control command for the system with ESMC is 0.8 V as compared to 9.8 V for the system with SMC. Additionally, the control command of the system with SMC is subjected to more chattering. These results conclude that a system with low controller gain in combination with the estimation of unknown payload parameters work better than a system with high controller gain without any estimation when there is no rider or payload. This study considers the length (Lr) and mass (Mr) of the rider as the parameters of interest. Variations in these parameters affect the rider's moment of inertia (Jr) and, consequently, the system's moment of inertia as described in Eq 26 and 24, respectively. Additionally, changes in these parameters affect the vehicle's center of gravity (L), but the effect is relatively low compared to the changes in the rider's moment of inertia.   The system becomes unstable with low controller gains when Mr is 150% of its nominal value (120kg) and Lr is 2.7. However, the proposed method can keep the system stable up to 250% of the nominal value of Mr with the same controller gains. The detail analysis is performed in results and discussion section where in section 6.1, performance of both controllers under small gains and maximum change in rider length and mass is conducted. In Fig 18 of manuscript, it can be seen that SMC controller with small controller gain is not able to maintain stability while the proposed method effectively stabilizes the system. Overall, the results of this study highlight the importance of considering the rider's length and mass as crucial parameters that affect the stability of self-balancing vehicles. Table 6 shows the maximum difference between the states and the control effort response of the two systems. State response performance of the SMC based system is better, yet the control effort response strengthens the utility of the proposed method.

Validation and comparison of proposed control algorithm
The performance of the proposed ESMC technique is compared with the earlier techniques in the literature to justify its novelty. Table 7 shows that Butler and Bright proposed a control technique using the linear quadratic regulator. They took into account the variation in payload but the maximum load considered was 70 kg as opposed to the 200 kg considered in the proposed ESMC technique. Additionally, the control response was very sluggish with a settling time of 10 seconds for the tilt angle, and no information about the control torque was provided. Shui-Chun Lin achieved stability using the linear adaptive robust controller. In these experiments, author incorporated the variation of payload but with a maximum of only 85 kg. Although, the settling time of the tilt angle was satisfactory, it experienced an undershoot of 5e-3 rad. No information regarding the control effort was provided for this case either. Zhao-Qin Guo used a sliding mode controller in combination with an observer to achieve robust control. Even though the study considered a static payload of just 1.6 kg, the controller response was sluggish with a settling time of 8 seconds and an undershoot of 0.02 rad. Moreover, oscillations of 0.05 units can be noted in the tilt angle and control effort. Nguyen Ngoc Son utilized an adaptive backstepping control technique to realize the stability of the SBR. Although, the controller response was quick with a settling time of 0.4 seconds, it only considered a static payload of 26 kg. The maximum control effort required for stability was a soaring 200 Nm in contrast to the 33 Nm requirement in the proposed ESMC technique. Byung Woo Kim examined an SBR with a dynamic load with a maximum of 85 kg using a backstepping controller with unknown control coefficients and model uncertainties. It took 3 seconds for the tilt angle to settle with an undershoot of 0.17 rad. The maximum required control effort, however, rocketed to 150 Nm with oscillations of ± 50 Nm. Nasim Esmaeili proposed a backstepping controller in combination with a two-layered SMC. This technique achieved upright stability within 1 second but experienced oscillations of magnitude ± 0.1 rad. Furthermore, it considered a 0.38 kg static payload, and the initial control torque requirement for stability was 4 V with an oscillation of ± 3 V. Ji-Hyun Park presented a hardware solution to the stability control problem by using a control moment gyroscope. An observer was used to estimate the disturbances and eventually actuate the control moment gyroscope. Stability control was achieved using a linear quadratic regulator. Tilt angle settled in around 1.5 seconds but experienced an oscillation of ± 0.02 rad. Additionally, the information regarding the control effort was not discussed. Finally, Thomas Johnson realized a perceptual control technique on a static payload of 0.5 kg. Even though it rejected disturbances effectively, the stability response was 1.5 seconds slower than the proposed technique with an undershoot, noticeable oscillations, and a steady-state error. The proposed technique can handle payloads up to 200kg with the maximum and initial required control effort of 3.3 V and 0.8 V, respectively, with no oscillation. The tilt angle settled in about 3.5 seconds with no steady-state error or oscillations.

Conclusions and recommendations
Most of the available solutions for the two-wheeled Self-Balancing Robot (SBR) either have constraint on the payload or their performance is compromised. In this work, a robust control with unknown payload parameters is realized, A detailed mathematical model, incorporating payload and motor dynamics, is derived and utilized to formulate the control equations for a Sliding Mode Controller (SMC). This controller along with an Extended Kalman Filter (EKF) is used to regulate the stability of the robot. Moreover, the detailed model of the SBR helps to improve the performance of the control system. EKF estimates the unknown parameters that are used as input to the SMC which in turn helps to boost the performance of the system. Rigorous simulations are carried out to validate the effectiveness of the proposed method for various scenarios using seven case studies. These simulation cases are identified according to the controller gain and payload variations. The results of the proposed method with parameter estimation (ESMC) are compared with the system without parameter estimation (SMC). It is illustrated that the performance of ESMC turns out to be better when similar control gains are used for both control systems. The combination of gains that exhibit a better performance for the SMC system, reveals a notable difference between the two systems in the initial control effort requirement for stability. The proposed technique is effective for the structured environment and indoor applications. It has a great scope for warehouses and predefined tasks for indoor environment. For future recommendations, the system may be subjected to the outdoor harsh environment that can introduce unwanted disturbances in the system. These issues along with performance targets may be addressed in the future work. Since, the mathematical model has a provision to accommodate disturbances, a solution may be developed in future to design control system for unstructured environment and outdoor applications. This further signifies the effectiveness of the proposed ESMC technique.

Nomenclature and acronyms
Constants and variables.